<template>
  <div>
    <button v-if="flag" @click="fn">按钮</button>
    <input type="text" v-else ref="abc" @blur="flag=true"/>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: true,
    };
  },
  methods: {
    fn() {
      this.flag = false;
      // console.log(this.$refs.abc);
      this.$nextTick(() => {
        // console.log(this.$refs.abc);
        this.$refs.abc.focus()
      }) 
    }
  }
};
</script>

<style scoped></style>
